using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Liberty.Application.ServiceMemberManagement;
using Liberty.Domain.ServiceMemberManagement;
using Liberty.Persistence.Kernel;

using Peradigm.Framework.Configuration;
using Peradigm.Framework.UI.Web;

namespace Liberty.UI.Service.ServiceMemberManagement.Controls
{

    public delegate void ServiceMemberSearchCompleteEventHandler( List<ServiceMember> serviceMembers );

    public partial class ServiceMemberSearchView : AbstractControl
    {
        #region Constants
        private static readonly DateTime NULL_DATE;
        private const string
            CONFIG_CONNECTION_STRING = "ConnectionString";
            


        #endregion

        #region Event Handlers
        protected void cmdSearch_Click( object sender, EventArgs e )
        {
            if( this.Page.IsPostBack )
            {
                ServiceMemberSearchCriteria criteria = new ServiceMemberSearchCriteria( txtLastName.Text );
                ServiceMemberController controller = new ServiceMemberController();
                this.RaiseSearchCompleteEvent( controller.ServiceMembersMatchingCriteria( criteria ) );
            }
        }

        protected void Page_Load( object sender, EventArgs e )
        {
        }
        #endregion

        #region Methods
        public override void UpdateView()
        {
            base.UpdateView();
            
        }
        #endregion

        #region Properties
        public event ServiceMemberSearchCompleteEventHandler SearchCompletedListeners
        {
            add
            {
                i_SearchCompleteEvent += value;
            }
            remove
            {
                i_SearchCompleteEvent -= value;
            }
        }

        #endregion

        #region Private Methods
        protected void RaiseSearchCompleteEvent( List<ServiceMember> serviceMembers )
        {
            if( this.SearchCompleteEvent != null )
            {
                this.SearchCompleteEvent( serviceMembers );
            }
        }
        #endregion

        #region Private Properties
        protected ServiceMemberSearchCompleteEventHandler SearchCompleteEvent
        {
            get
            {
                return i_SearchCompleteEvent;
            }
        }
        #endregion

        #region Construction and Finalization
        static ServiceMemberSearchView()
        {
            NULL_DATE = DateTime.MinValue;
        }

        public ServiceMemberSearchView()
            : base()
        {
        }
        #endregion

        #region Data Elements
        private ServiceMemberSearchCompleteEventHandler i_SearchCompleteEvent;
        #endregion

        #region Types
        #endregion
    }

}